﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpIM.Http
{
    public abstract class HttpApi : IDisposable
    {
        public HttpContext HttpContext { get; internal set; }

        #region IDisposable Support
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    if (HttpContext.Response.Output != null)
                    {
                        HttpContext.Response.Output.Dispose();
                        HttpContext.Response.Output = null;
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }

        // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
        // ~HttpApi() {
        //   // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
        //   Dispose(false);
        // }

        // This code added to correctly implement the disposable pattern.
        void IDisposable.Dispose()
        {
            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
            Dispose(true);
            // TODO: uncomment the following line if the finalizer is overridden above.
            // GC.SuppressFinalize(this);
        }
        #endregion
    }

    public class HomeApi : HttpApi
    {
        public void Values()
        {

        }
        public string SetPassword(string username, string password)
        {
            return username + password;
        }

        public object SetPassword2(User user, User m, string abc = null)
        {
            // SEE NETTY SOURCE CODE FOR MORE INFOMRATION
            return user;
        }

        public class User
        {
            public string Username { get; set; }
            public string password { get; set; }
            //public User user { get; set; }
        }
        public class User2 : User
        {
            public string K { get; set; }
        }
    }
}
